/*
 ==============================================================================
 
 JUCE library : Starting point code, v1.26
 Copyright 2005 by Julian Storer. [edited by haydxn, 3rd April 2007]
 
 ------------------------------------------------------------------------------
 
 MainComponent.h :
 
 This file defines the behaviour of the application. The main part of the
 program that the user interacts with IS this MainComponent object. It is
 placed within the MainAppWindow instance, and so exists at whatever size
 the window provides in its content area.
 
 All of the widgets and controls that your main program window will display
 will be on this component (either directly or somewhere down the children
 hierarchy).
 
 ------------------------------------------------------------------------------
 
 Please feel free to do whatever you like with this code, bearing in mind that
 it's not guaranteed to be bug-free!
 
 ==============================================================================
 */
#ifndef _TEVOLUTIONCOMPONENT_H_
#define _TEVOLUTIONCOMPONENT_H_


/*
 Using <juce/juce.h> here assumes the juce source tree is accessible via one
 of the following paths (depending on the Xcode project settings)
 
 /Developer/SDKs/MacOSX10.5.sdk/usr/include/
 /Developer/SDKs/MacOSX10.4u.sdk/usr/include/
 /usr/include
 
 On other platforms just use juce.h making it available in the search path 
 */
#include "juce_amalgamated.h"	

//==============================================================================
// just a component that deletes all its children, to use for the tabbed pages to avoid
// memory leaks when they're deleted
class DemoPageComp  : public Component
	{
	public:
		DemoPageComp()
		{
		}
		
		~DemoPageComp()
		{
			deleteAllChildren();
		}
	};

//==============================================================================

static Component* createSlidersPage()
{
    DemoPageComp* page = new DemoPageComp();
	
    const int numSliders = 11;
    Slider* sliders [numSliders];
	
    int i;
    for (i = 0; i < numSliders; ++i)
    {
        if (i == 2)
            page->addAndMakeVisible (sliders[i] = new Slider (T("slider")));
        else
            page->addAndMakeVisible (sliders[i] = new Slider (T("slider")));
		
        sliders[i]->setRange (0.0, 100.0, 0.1);
        sliders[i]->setPopupMenuEnabled (true);
        sliders[i]->setValue (Random::getSystemRandom().nextDouble() * 100.0, false, false);
    }
	
    sliders[0]->setSliderStyle (Slider::LinearVertical);
    sliders[0]->setTextBoxStyle (Slider::TextBoxBelow, false, 100, 20);
    sliders[0]->setBounds (10, 25, 70, 200);
    sliders[0]->setDoubleClickReturnValue (true, 50.0); // double-clicking this slider will set it to 50.0
    sliders[0]->setTextValueSuffix (T(" units"));
	
    sliders[1]->setSliderStyle (Slider::LinearVertical);
    sliders[1]->setVelocityBasedMode (true);
    sliders[1]->setSkewFactor (0.5);
    sliders[1]->setTextBoxStyle (Slider::TextBoxAbove, true, 100, 20);
    sliders[1]->setBounds (85, 25, 70, 200);
    sliders[1]->setTextValueSuffix (T(" rels"));
	
    sliders[2]->setSliderStyle (Slider::LinearHorizontal);
    sliders[2]->setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20);
    sliders[2]->setBounds (180, 35, 150, 20);
	
    sliders[3]->setSliderStyle (Slider::LinearHorizontal);
    sliders[3]->setTextBoxStyle (Slider::NoTextBox, false, 0, 0);
    sliders[3]->setBounds (180, 65, 150, 20);
    sliders[3]->setPopupDisplayEnabled (true, page);
    sliders[3]->setTextValueSuffix (T(" nuns required to change a lightbulb"));
	
    sliders[4]->setSliderStyle (Slider::IncDecButtons);
    sliders[4]->setTextBoxStyle (Slider::TextBoxLeft, false, 50, 20);
    sliders[4]->setBounds (180, 105, 100, 20);
    sliders[4]->setIncDecButtonsMode (Slider::incDecButtonsDraggable_Vertical);
	
    sliders[5]->setSliderStyle (Slider::Rotary);
    sliders[5]->setRotaryParameters (float_Pi * 1.2f, float_Pi * 2.8f, false);
    sliders[5]->setTextBoxStyle (Slider::TextBoxRight, false, 70, 20);
    sliders[5]->setBounds (190, 145, 120, 40);
    sliders[5]->setTextValueSuffix (T(" mm"));
	
    sliders[6]->setSliderStyle (Slider::LinearBar);
    sliders[6]->setBounds (180, 195, 100, 30);
    sliders[6]->setTextValueSuffix (T(" gallons"));
	
    sliders[7]->setSliderStyle (Slider::TwoValueHorizontal);
    sliders[7]->setBounds (360, 20, 160, 40);
	
    sliders[8]->setSliderStyle (Slider::TwoValueVertical);
    sliders[8]->setBounds (360, 110, 40, 160);
	
    sliders[9]->setSliderStyle (Slider::ThreeValueHorizontal);
    sliders[9]->setBounds (360, 70, 160, 40);
	
    sliders[10]->setSliderStyle (Slider::ThreeValueVertical);
    sliders[10]->setBounds (440, 110, 40, 160);
	
    for (i = 7; i <= 10; ++i)
    {
        sliders[i]->setTextBoxStyle (Slider::NoTextBox, false, 0, 0);
        sliders[i]->setMinValue (Random::getSystemRandom().nextDouble() * 100.0, false, false);
        sliders[i]->setMaxValue (Random::getSystemRandom().nextDouble() * 100.0, false, false);
        sliders[i]->setPopupDisplayEnabled (true, page);
    }
	
    Label* label = new Label (T("hint"), T("Try right-clicking on a slider for an options menu. \n\nAlso, holding down CTRL while dragging will turn on a slider's velocity-sensitive mode"));
    label->setBounds (20, 245, 350, 150);
    page->addAndMakeVisible (label);
	
    return page;
}

//==============================================================================

class TevolutionTabsComponent : public TabbedComponent,
								public ButtonListener
{
public:
    TevolutionTabsComponent ();
    ~TevolutionTabsComponent();
    void buttonClicked (Button* button);
    static const Colour getRandomBrightColour();
};

//==============================================================================

class TevolutionComponent  :	public Component,
								public ButtonListener
{
    ToggleButton* enableButton;	
    TevolutionTabsComponent* tabs;
	
public:
    //==============================================================================
    TevolutionComponent ();
    ~TevolutionComponent();
    void resized();
	void paint (Graphics& g);
	
    //==============================================================================
    void buttonClicked (Button* button);
};

//==============================================================================

#endif//_TEVOLUTIONCOMPONENT_H_ 